﻿<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="CustomerImport.aspx.cs"
    Inherits="CrmContacto.WebApp.App.CustomerImport" %>

<%@ Import Namespace="Web.Framework.Translate" %>
<%@ Import Namespace="System" %>
<%@ Register Assembly="Web.Framework" Namespace="Web.Framework.Controls" TagPrefix="Crm" %>
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="/Styles/App/CustomerImport.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function () {
            // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
            $("#dialog:ui-dialog").dialog("destroy");

            $("#dialogmodalprocesando").dialog({
                height: 140,
                autoOpen: false,
                width: 'auto',
                modal: true
            });
        });

        $(function () {
            // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
            $("#dialog:ui-dialog").dialog("destroy");

            $("#dialogmodalarchivosubido").dialog({
                modal: true,
                autoOpen: false,
                width: 'auto',
                buttons: {
                    Ok: function () {
                        $(this).dialog("close");
                        location.href = location.href;
                        //__doPostBack($('#lnkVerResultados').attr('aspnetid'), '');                        
                        //lnkVerResultados
                    }
                }
            });
        });         

    </script>
    <style type="text/css">
         .gridmessagecolumn
         {
             color: Red;
         }
    </style>
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        <asp:Image Width="15px" Height="15px" ID="imgExpandResults" CssClass="imgExpand"
            ImageUrl="/Images/icon_blockexpanded.png" runat="server" ClientIDMode="Static"
            alt="" onclick="window.AppCommonObj.toggleVisibility(this.id, 'searchBox');" />
        <asp:Literal ID="Literal22" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.CustomerImport.Title"]%>' />
    </h2>
    <div id="searchBox">
        <asp:LinkButton ID="lnkImportarContactos" runat="server" ClientIDMode="Static" CssClass="agregarNuevo">
            <img class="excelicon" src="/Images/excel.png" alt="Excel" style="text-decoration: none; border: 0px;" /><asp:Literal
                ID="Literal2" runat="server" Text='<%$ Code:  LocalizationProvider.Instance["Bo.CustomerImport.cmdImportar"]%>' /></asp:LinkButton>
        <a id="lnkBajarEjemplo"  href='<%= System.String.Format("../SampleFiles/ImportCustomer.{0}.xlsx", Pais) %>' class="agregarNuevo">
            <img class="excelicon" src="/Images/excel.png" alt="Excel" style="text-decoration: none; border: 0px;" /><asp:Literal
                ID="Literal3" runat="server" Text='<%$ Code:  LocalizationProvider.Instance["Bo.CustomerImport.SampleFile"]%>' /></a>
        <div class="clear">
        </div>
    </div>
    <br />
    <asp:Panel ID="pnlCustomers" runat="server" ClientIDMode="Static" Visible="False">
        <h2>
            <asp:Image Width="15px" Height="15px" ID="Image1" CssClass="imgExpand" ImageUrl="/Images/icon_blockcollapsed.png"
                runat="server" ClientIDMode="Static" alt="" onclick="window.AppCommonObj.toggleVisibility(this.id, 'pnlResults');" />
            <asp:Literal ID="Literal1" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.CustomerImport.ContactosImportadosTitle"]%>' />
            <asp:Label ID="Label1" runat="server" Text="" CssClass="lblSearchResult"></asp:Label>
        </h2>
        <asp:Panel ID="pnlResults" CssClass="editionContainerForGrid" runat="server" ClientIDMode="Static">
            <asp:GridView ID="Grid" runat="server" CellPadding="4" ForeColor="#333333"
                GridLines="None" AutoGenerateColumns="False" DataKeyNames="Id" Width="100%" AllowPaging="False"
                OnRowCommand="Grid_RowCommand"
                OnRowDataBound="Grid_RowDataBound">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:ButtonField ButtonType="Image" CommandName="editar" ImageUrl="~/Images/editar.png"
                        Text="Button" AccessibleHeaderText="editar">
                        <HeaderStyle HorizontalAlign="Left" Width="30px" />
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:ButtonField>                
                     <asp:CheckBoxField DataField="FueIncorporado" HeaderText='<%$ Code:  LocalizationProvider.Instance["Bo.CustomerImport.FueIncorporando"] %>' >                        
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:CheckBoxField>
                    <asp:BoundField DataField="Email" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.Email"] %>'
                        >
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Nombre" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.Nombre"] %>'
                        >
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Apellido" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.Apellido"] %>'
                        >
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>                   
                    <asp:BoundField DataField="Dni" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.DocumentoShort"] %>'
                        >
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                     <asp:CheckBoxField DataField="TieneErrores" HeaderText='<%$ Code:  LocalizationProvider.Instance["Bo.CustomerImport.TieneErrores"] %>' >                        
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:CheckBoxField>
                    <asp:BoundField DataField="Mensaje" HeaderText='<%$ Code:  LocalizationProvider.Instance["Bo.CustomerImport.Mensaje"] %>'
                        >
                        <HeaderStyle HorizontalAlign="Left" />
                        <ItemStyle CssClass="gridmessagecolumn" />
                    </asp:BoundField>        
                </Columns>
                <EditRowStyle BackColor="#2461BF" />
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#4b6c9e" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
                <PagerStyle BackColor="#4b6c9e" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#EFF3FB" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#F5F7FB" />
                <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                <SortedDescendingCellStyle BackColor="#E9EBEF" />
                <SortedDescendingHeaderStyle BackColor="#4870BE" />
            </asp:GridView>
        </asp:Panel>
    </asp:Panel>

    <asp:LinkButton ID="lnkVerResultados" ClientIDMode="Static" runat="server" OnClick="lnkVerResultados_Click"></asp:LinkButton>

    <script type='text/javascript'>

        $(document).ready(function () {

            if (!window.AppCommonObj) {
                window.AppCommonObj = new AppCommon();
            }

            //$('input[title]').inputHints();

        });

        $(function () {

            //Function to upload file.
            new AjaxUpload('#lnkImportarContactos', {
                action: '../Handler/FileUploadCustomers.UC',
                name: 'UC',
                onComplete: function (file, response) {
                    $("#dialogmodalprocesando").dialog('close');

                    // Submit de otro botón que tomará los valores de la sessión
                    $('#dialogmodalarchivosubido').html(response);
                    $('#dialogmodalarchivosubido').dialog('open');
                },

                onSubmit: function (file, ext) {
                    if (!(ext && /^(xls|xlsx)$/i.test(ext))) {
                        $('#dialogmodalarchivosubido').html("<asp:Literal ID="Literal422" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.CustomerImport.Arch.SoloExcel"]%>' ></asp:Literal>");
                        $('#dialogmodalarchivosubido').dialog('open');
                        return false;
                    }

                    $("#dialogmodalprocesando").dialog('open');
                    return true;
                }
            });
        });                

    </script>
    <div id="dialogmodalprocesando" title="<asp:Literal ID="Literal423" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.CustomerImport.Arch.Incorporando"]%>' ></asp:Literal>" style="text-align: center; vertical-align: middle">
        <img alt="" src="/Images/roller_orange.gif" style="margin-top: 30px" />
    </div>
    <div id="dialogmodalarchivosubido" title="<asp:Literal ID="Literal4" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.CustomerImport.Arch.Procesado"]%>' ></asp:Literal>" >
    </div>
</asp:Content>
